﻿using System;
using System.Windows;

namespace Budgetsch
{
    using System.Windows.Controls;
    using System.Windows.Navigation;
using Budgetsch.Web.Services;

    /// <summary>
    /// Home page for the application.
    /// </summary>
    public partial class Home : Page
    {
        private BudgetschDomainContext m_context;
        /// <summary>
        /// Creates a new <see cref="Home"/> instance.
        /// </summary>
        public Home()
        {
            InitializeComponent();

            this.Title = ApplicationStrings.HomePageTitle;
        }

        protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            base.OnNavigatingFrom(e);
            if(!WebContext.Current.Authentication.User.Identity.IsAuthenticated)
            {
                e.Cancel = true;
                MessageBox.Show("Login is neccessary to use the system!");
            }
        }

        /// <summary>
        /// Executes when the user navigates to this page.
        /// </summary>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void Incomes_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/IncomesView",UriKind.Relative));
        }

        private void Costs_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/CostsView", UriKind.Relative));
        }

        private void Savings_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/SavingsView", UriKind.Relative));
        }

        private void Profile_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/ProfileView", UriKind.Relative));
        }
    }
}